package com.cjy;

public class ComparableDemo1 implements Comparable<ComparableDemo1>{

    private double long1;
    private double wide1;
    public ComparableDemo1(){}
    public ComparableDemo1(double a,double b){
        this.long1=a;
        this.wide1=b;
    }
    public double getLong1() {
        return long1;
    }
    public void setLong1(double long1) {
        this.long1 = long1;
    }

    public double getWide1() {
        return wide1;
    }

    public void setWide1(double wide1) {
        this.wide1 = wide1;
    }

    public double getArea(){
        return long1*wide1;
    }
    public int compareTo(ComparableDemo1 o) {
        if (getArea() > o.getArea())
            return 1;
        else if (getArea() < o.getArea())
            return -1;
        else
            return 0;
    }
    public String toString() {
        return "Width: " + getLong1() + " Height: " + getWide1() +
                " Area: " +  getArea();
    }
}
